package com.tarena.lbs.business.controller;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.business.pojo.param.BusinessParam;
import com.tarena.lbs.business.pojo.query.BusinessQuery;
import com.tarena.lbs.business.pojo.vo.BusinessStoreVO;
import com.tarena.lbs.business.pojo.vo.BusinessVO;
import com.tarena.lbs.business.servcie.BusinessService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 处理和商家相关的接口功能
 */
@Slf4j
@RestController
@Tag(name = "商家相关功能接口")
public class BusinessController {
    @Autowired
    private BusinessService businessService;
    @Operation(summary = "查询商家列表")
    @GetMapping("/admin/basic/business/info/list")
    public Result<List<BusinessVO>> pageList(BusinessQuery query)
            throws BusinessException {
        log.debug("查询商家列表，前端传来的"+query);
        List<BusinessVO> businessList= businessService.selectList(query);
        return new Result<>(businessList);
    }
    @Operation(summary = "保存商家信息")
    @PostMapping("/admin/basic/business/info/save")
    public Result<Void> save(@RequestBody BusinessParam param) {
        log.debug("保存商家信息，入参：{}",param);
        businessService.save(param);
        return Result.success();
    }
    @Operation(summary = "查询商家详情")
    @GetMapping("basic/business/info/detail/{id}")
    public Result<BusinessStoreVO> busiStoreDetail(@PathVariable("id") Integer businessId) {
        BusinessStoreVO businessStoreVO=businessService.businessStoreDetail(businessId);
        return new Result<>(businessStoreVO);
    }
}
























